# -*- coding: utf-8 -*-
import os
import sys
from datetime import datetime

pwd = os.path.dirname(os.path.dirname(__file__))

# 进入django设置
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'shop.settings')

import django

django.setup()

from managements.models import MenuList, RoleList, ReturnAddress, SystemSet, ReturnReason

data = {"code": 200, "message": "操作成功", "data": {"pageNum": 1, "pageSize": 5, "totalPage": 2, "total": 9, "list": [
    {"id": 1, "name": "7天无理由退货", "sort": 1, "status": 1, "createTime": "2018-10-17T02:01:47.000+00:00"},
    {"id": 2, "name": "颜色不喜欢", "sort": 1, "status": 1, "createTime": "2018-10-17T02:01:13.000+00:00"},
    {"id": 3, "name": "尺码太大", "sort": 1, "status": 1, "createTime": "2018-10-17T02:01:03.000+00:00"},
    {"id": 4, "name": "尺码太小", "sort": 1, "status": 1, "createTime": "2018-10-17T02:01:03.000+00:00"},
    {"id": 5, "name": "质量问题", "sort": 1, "status": 1, "createTime": "2018-10-17T02:00:45.000+00:00"},
    {"id": 6, "name": "物流问题", "sort": 1, "status": 1, "createTime": "2018-10-17T02:01:47.000+00:00"},
    {"id": 7, "name": "价格问题", "sort": 1, "status": 0, "createTime": "2018-10-17T02:01:57.000+00:00"},
    {"id": 7, "name": "其他", "sort": 1, "status": 0, "createTime": "2018-10-17T02:01:57.000+00:00"}
]}}

for item in data['data']['list']:
    reason = ReturnReason()
    reason.name = item['name']
    reason.sort = item['sort']
    reason.is_display = item['status']
    reason.add_time = item['createTime']
    reason.save()
